<?php
/**
 * Created by PhpStorm
 * @package app\api\validate
 * User: Brahma
 * Date: 2022/3/24
 * Time: 11:40 上午
 */

namespace app\api\validate;


use think\Validate;

class LoginValidate extends Validate {
	protected $rule = [
		'mobile'           => 'require|/^1\d{10}$/',
		'code'             => 'require|number',
		'password'         => 'require',
		're_password'      => 'require',
		'invitation_code'  => 'require',
		'nickname'         => 'require',
		'bank_name'        => 'require',
		'bank_card_no'     => 'require',
		'bank_card_holder' => 'require',
		'name'             => 'require',
		'address_now'      => 'require',
		'address'          => 'require',
		'is_default'       => 'require|in:0,1',
	];
	protected $message = [
		'mobile.require'           => '手机号不能为空',
		'mobile./^1\d{10}$/'       => '请输入正确的手机号',
		'code.require'             => '验证码不能为空',
		'nickname.require'         => '昵称不能为空',
		'code.number'              => '验证码格式不正确',
		'password.require'         => '密码不能为空',
		're_password.require'      => '重复密码不能为空',
		'invitation_code.require'  => '邀请码不能为空',
		'bank_name.require'        => '所属银行不能为空',
		'bank_card_no.require'     => '银行卡号不能为空',
		'bank_card_holder.require' => '持有人姓名不能为空',
		'name.require'             => '收件人姓名不能为空',
		'address_now.require'      => '所在地区不能为空',
		'address.require'          => '详细地址不能为空',
		'is_default.require'       => '请选择默认地址',
		'is_default.in'            => '默认地址参数错误',
	];
	protected $scene = [
		'register'           => ['mobile', 'code', 'password', 're_password', 'invitation_code', 'nickname'],
		'sms'                => ['mobile'],
		'back_psw'           => ['mobile', 'code', 'password'],
		'login'              => ['mobile', 'password'],
		'bank_info_write'    => ['bank_name', 'bank_card_no', 'bank_card_holder'],
		'address_info_write' => ['name', 'mobile', 'address_now', 'address', 'is_default'],
	];
}
